﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace LDCRNewEdit.CustomCompent
{
    class MyCheckBoxColumn : DataGridViewCheckBoxColumn
    {
        public override DataGridViewCell CellTemplate
        {

            get
            {

                return new MyCheckBoxCell();

            }

        }

    }

    public class MyCheckBoxCell : DataGridViewCheckBoxCell
    {

        protected override void Paint(System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {


            base.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);

            Rectangle contentBounds = this.GetContentBounds(rowIndex);

            // Compute the location where we want to paint the string.

            Point stringLocation = new Point();

            // Compute the Y.

            // NOTE: the current logic does not take into account padding.

            stringLocation.Y = cellBounds.Y + 2;

            // Compute the X.

            // Content bounds are computed relative to the cell bounds

            // - not relative to the DataGridView control.

            stringLocation.X = cellBounds.X + contentBounds.Right + 2;

            // Paint the string.

            graphics.DrawString(ToolTipText, Control.DefaultFont, System.Drawing.Brushes.Black, stringLocation);

            Point drawInPoint = new Point(cellBounds.X + cellBounds.Width / 2 - 7, cellBounds.Y + cellBounds.Height / 2 - 7);
        }
    }
}
